<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            width: 200px;
            height: 200px;
            background-image: linear-gradient(to right,red,yellow);
/*可以用background-image: linear-gradient来设置背景图的渐变色
设置渐变方向的方法：
  1.to left, to right, to top, to bottle
  2.deg
  3.turn
设置颜色所占比例：直接在颜色后面加像素
渐变也可以指定多个颜色
*/
        }
        .box2{
            width: 200px;
            height: 200px;
            background-image: linear-gradient(45deg,red, yellow,skyblue);
        }
        .box3{
            width: 200px;
            height: 200px;
            background-image: linear-gradient(1turn,red,yellow);
            background-image: repeating-linear-gradient(red,yellow,purple 60px); 
/*background-image: repeating-linear-gradient用于设置重复的渐变背景*/
        }

    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
</body>
</html>